<template>
  <div id="app">
    <Game />
  </div>
</template>

<script>
import Game from "./components/Game";
import Vue from "vue";
import levelData from "@/store/levelData";
import getMaxArr from "@/utils/getMaxArr";
export default {
  name: "App",
  components: {
    Game,
  },
  data() {
    return {
      infoStore: this.$store.state.info,
    };
  },
  async mounted() {
    // try {
    //   const resp = await fetch(
    //     "https://game-two-1310591936.cos.ap-nanjing.myqcloud.com/data/users.json",
    //     {
    //       method: "put",
    //       headers: {
    //         Authorization:
    //           "q-sign-algorithm=sha1&q-ak=AKID4wYv2tUu5zd0qPilY5LL6aomTv72h6F8&q-sign-time=1664186497;1689190097&q-key-time=1664186497;1689190097&q-header-list=&q-url-param-list=&q-signature=2841b0ee5397966b53e70ac33d0ac8d346e355da",
    //         "Content-Type": "application/json",
    //       },
    //       body: JSON.stringify([
    //         { userName: "asdtest", pwd: "xxxxxx", cards: "" },
    //       ]),
    //     }
    //   );
    //   const data = {};
    //   data.status = resp.status; // 状态码
    //   data.data = await resp.text(); // 响应体
    //   console.log(data);
    // } catch (err) {
    //   console.log(err);
    // }

    Vue.prototype.$type = this.type;
    Vue.prototype.$consolelog = this.consolelog;
    // console.log("[]", this.type([]));     // [object Array]
    // console.log("{}", this.type({}));     // [object Object]
    // console.log("12", this.type(12));     // number
    // console.log("dfs", this.type("dfs")); // string
    // console.log("new Number(1)", this.type(new Number(1))); // [object Number]
    // console.log("null", this.type(null));                   // [object Null]
    // console.log("undefined", this.type(undefined));         // undefined
  },
  methods: {
    // 返回数据类型
    type(arg) {
      var tp = typeof arg;
      var tostr = Object.prototype.toString;
      return tp == "object" ? tostr.call(arg) : tp;
    },
    // 打印至run js编辑器窗口
    consolelog(...args) {
      let str = this.infoStore.textarea + "\n/*\n";
      for (let index = 0; index < args.length; index++) {
        const atype = this.type(args[index]);
        str += args[index] + " ";
        if (atype === "[object Array]") {
          // 数组
          for (let i = 0; i < args[index].length; i++) {
            str += `\n  ${i}: ${args[index][i]}`;
          }
          str += "\n";
        } else if (atype === "[object Object]") {
          // 对象
          for (let key in args[index]) {
            if (args[index].hasOwnProperty(key)) {
              str += `\n  ${key}: ${args[index][key]}`;
            }
            str += "\n";
          }
        }
      }
      this.$store.commit("info/setTextarea", str + "\n*/\n");
    },
  },
};
</script>

<style lang="less">
@import "~@/styles/var.less";
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
body {
  background: @bg;
  margin: 0;
  padding: 0;
}
// 通知
div.el-notification {
  width: 250px;
}
// 通知的关闭按钮
div.el-notification__closeBtn.el-icon-close {
  width: 25px;
  height: 25px;
  font-size: 25px;
  margin-top: -8px;
  margin-right: -5px;
  word-wrap: break-word;
}
// 提示
div.el-message.is-closable {
  i.el-message__icon {
    width: 20px;
    height: 20px;
    font-size: 20px;
  }
  p.el-message__content {
    font-size: 14px;
  }
  i.el-message__closeBtn.el-icon-close {
    width: 25px;
    height: 25px;
    font-size: 25px;
    margin-right: -6px;
  }
}
</style>
